#!/bin/bash

path="$(pwd -W)"
filename="cantest"
if [ "$1" == "stm32" ]; then
    openocd -s "$path" -f interface/stlink.cfg -f target/stm32f1x.cfg -c "program \"$path/build/$filename/$filename.hex\" verify" -c "reset run" -c "exit"
elif [ "$1" == "gd32" ]; then
    openocd -s "$path" -f interface/stlink.cfg -f target/stm32f1x.cfg -c "program \"$path/build/$filename/$filename.hex\" verify" -c "reset run" -c "exit"
else
    echo "Usage: $0 [stm32|gd32]"
    exit 1
fi
